import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;

import sun.net.TelnetInputStream;
import sun.net.ftp.FtpClient;
import sun.net.ftp.FtpLoginException;
 
public class FtpAction
{	 
	private FtpClient ftp = null;
	private List list = new List();
    
/*	FtpAction()
	{
	}
*/	 
	public String getDir(String path) {
		String dirName;
//         int ch;
		int begin = 55;
		dirName = path.substring(begin).trim();
		return dirName;
	}
 
	public void loadList(FtpClient ftp) {
		StringBuffer buf = new StringBuffer();
		int ch;

		list.removeAll();
		try {
			TelnetInputStream t = ftp.list();
			t.setStickyCRLF(true);
			while ( (ch = t.read()) >= 0) {
				if (ch == '\n') {
					list.add(getDir(buf.toString()));
					buf.setLength(0);
				}
				else {
					buf.append( (char) ch);
				}
			}
		}
		catch (IOException e) {
			e.printStackTrace();
		}
		list.validate();
	}

	public FtpClient getFtp() {
		return ftp;
	}

	public void setFtp(FtpClient ftp) {
		this.ftp = ftp;
	}
	public List getList() {
		return list;
	}

	public void setList(List list) {
		this.list = list;
	}	 

 }
